//
//  BaseCell.m
//  IpadR
//
//  Created by edianzu on 2017/5/25.
//  Copyright © 2017年 ruilai. All rights reserved.
//

#import "BaseCell.h"

@implementation BaseCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

//生日转年龄 精确到天(由于项目需要稍作修改，目前是精确到年)
-(NSString *)dateToDetailOld:(NSDate *)bornDate{
    //获得当前系统时间
    NSDate *currentDate = [NSDate date];
    //创建日历(格里高利历)
    NSCalendar *calendar = [NSCalendar currentCalendar];
    //设置component的组成部分
    NSUInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond ;
    //按照组成部分格式计算出生日期与现在时间的时间间隔
    NSDateComponents *date = [calendar components:unitFlags fromDate:bornDate toDate:currentDate options:0];
    NSString * str = [NSString stringWithFormat:@"%ld",(long)[date year]];
    return str;
    //判断年龄大小,以确定返回格式
//    if( [date year] > 0)
//    {
//        return [NSString stringWithFormat:(@"%ld岁%ld月%ld天"),(long)[date year],(long)[date month],(long)[date day]];
//        
//    }
//    else if([date month] >0)
//    {
//        return [NSString stringWithFormat:(@"%ld月%ld天"),(long)[date month],(long)[date day]];
//        
//    }
//    else if([date day]>0)
//    {
//        return [NSString stringWithFormat:(@"%ld天"),(long)[date day]];
//        
//    }
//    else {
//        return @"0天";
//    }
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
